from Base import Base
from selenium.webdriver.common.by import By
import time

class Page(Base):
    search_loc = (By.ID,'query')
    def se(self):
        self.find_element(self.search_loc).is_displayed()

    def search(self):
        self.send_keys(self.search_loc,'软件测试自动化')

    next_loc = (By.ID,'stb')
    def next(self):
        self.click(self.next_loc)

    search_title_loc = (By.XPATH,'//h3[@class="vr-title  "]/a')
    def search_title(self):
        a = self.find_elements(self.search_title_loc)
        for i in a:
            print(i.text)

    nextpage_loc = (By.ID,'sogou_next')
    def nextpage(self):
        self.click(self.nextpage_loc)

    def luoji_01_search(self):
        self.open_url('https://www.sogou.com/')
        print(self.title())
        assert '搜狗' in self.title()
        self.se()
        self.search()
        self.next()
        print(self.title())
        assert '软件测试自动化' in self.title()
        print("第一页")
        self.search_title()
        assert '软件测试' in self.search_title()
        self.nextpage()
        print("第二页")
        self.search_title()
        assert '软件测试' in self.search_title()